//Accepted
#include <cstdio>
int n, h, m, s, c;
long long sum;
int main(){
	//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);
	while(scanf("%2d%2d%2d%2d", &h,&m,&s,&c)==4){
		sum = h*360000+m*6000+s*100+c;
		printf("%07u\n", (sum*500)/432);
	}
	return 0;
}
